package com.study.a10Test5;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {

        Socket socket=new Socket("127.0.0.1",9000);

        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("E:\\java-code\\idea-code-study\\mysocketnet\\cilentdir\\磁石骰2.png"));

        BufferedOutputStream bos=new BufferedOutputStream(socket.getOutputStream());
        byte[] bytes=new byte[1024*1024*5];
        int len;
        while((len=bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
        }

        //结束标记
        socket.shutdownOutput();

        //接收服务器回写数据
        BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String str=br.readLine();
        System.out.println(str);

        bos.flush();
        //关闭资源

        socket.close();

    }
}
